#include "Potential.h"

const double Potential::epsilon = 0.5;

Potential::Potential()
{
  this->K = 0;
  this->A = 0;
  p = NULL;
}

Potential::Potential(double K,double range,Position* pos)
{
  this->K = K;
  this->A = (-1.0/(range*range))*log(abs(epsilon/K));
  p = pos;
}

Vector Potential::calcForce(Position* atPos)
{
  Vector diff = Vector(atPos) - Vector(p);
  double dist_sq = diff.lengthSq();
  double magnitude = K*exp(-A*dist_sq);
  diff.normalize();
  diff.scale(magnitude);
  return diff;
}
